package com.woniu.model.mallSystem.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 商品表
 * </p>
 *
 * @author Lzj
 * @since 2023-10-19
 */
@Getter
@Setter
@TableName("t_commodity")
@ApiModel(value = "Commodity对象", description = "商品表")
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "commodity_list")
public class Commodity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("商品表id")
    @TableId(value = "id", type = IdType.AUTO)
    // 指定es中文件的主键id
    @Id
    private Long id;

    // 指定es的分词器与字段类型(json的key的类型)
    @Field(analyzer = "ik_max_word", type = FieldType.Text)
    @ApiModelProperty("商品名")
    private String name;
    @Field(type = FieldType.Integer)
    @ApiModelProperty("商品类别id")
    private Integer tCategoryId;

    @Field(type = FieldType.Integer)
    @ApiModelProperty("商品图片地址")
    private Long imgId;

    @Field(analyzer = "ik_max_word", type = FieldType.Text)
    @ApiModelProperty("商品标题")
    private String title;

    @Field(analyzer = "ik_smart", type = FieldType.Text)
    @ApiModelProperty("副标题")
    private String subhead;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("商品编码")
    private String code;

    @Field(type = FieldType.Double)
    @ApiModelProperty("商品价格")
    private BigDecimal price;

    @Field(type = FieldType.Double)
    @ApiModelProperty("商品原价")
    private BigDecimal originalPrice;


    @Field(type = FieldType.Integer)
    @ApiModelProperty("库存")
    private Integer stock;

    @Field(type = FieldType.Integer)
    @ApiModelProperty("商品状态(未上架0、已上架1、已下架2、待审核3、未通过4）")
    private Integer status;

    @Field(type = FieldType.Integer)
    @ApiModelProperty("商品排序")
    private Integer sequence;

    @Field(type = FieldType.Integer)
    @ApiModelProperty("库存预警")
    private Integer stockWarn;

    @Field(analyzer = "ik_smart", type = FieldType.Text)
    @ApiModelProperty("商品详情")
    private String details;

//    @ApiModelProperty("缩略图")
//    private String goodsPhoto;

//    @ApiModelProperty("相册")
//    private String bigPhoto;
    @TableLogic //逻辑删除
    @Field(type = FieldType.Integer)
    @ApiModelProperty("删除标志")
    private Integer deleteFlag;

    @Override
    public String toString() {
        return "Commodity{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", tCategoryId=" + tCategoryId +
                ", imgId=" + imgId +
                ", title='" + title + '\'' +
                ", subhead='" + subhead + '\'' +
                ", code='" + code + '\'' +
                ", price=" + price +
                ", originalPrice=" + originalPrice +
                ", stock=" + stock +
                ", status=" + status +
                ", sequence=" + sequence +
                ", stockWarn=" + stockWarn +
                ", details='" + details + '\'' +
                ", deleteFlag=" + deleteFlag +
                '}';
    }
}
